home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / utilities / blankers / blitzblank_260 / developer / modulesources / bb.crumble.c < prev    next >
C/C++ Source or Header  |  1995-02-28  |  4KB  |  159 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5. #include <dos/dos.h>
  6. #include <exec/memory.h>
  7. #include <intuition/intuitionbase.h>
  8. #include <intuition/screens.h>
  9. #include <intuition/intuition.h>
  10. #include <proto/exec.h>
  11. #include <proto/intuition.h>
  12. #include <proto/graphics.h>
  13. #include <pragmas/blitzblank_pragmas.h>
  14. #include <BlitzBlank.h>
  15.  
  16. struct Library *BlitzBlankBase;
  17. static const char version[]="$VER: BB.Crumble 2.50 (25.12.94)";
  18.  
  19. char *text[]={"\33c\33uCrumble\33n\n\nModule for BlitzBlank\n\nCopyright 1994\nby\nThomas Börkel",
  20.               "Sp_eed:",
  21.               "Da_rk Background:",
  22.               "_Brightness",
  23.               "_Delay:" };
  24.  
  25. struct BB_Object object[]={ {&object[1],BB_VGroup,0,0,0,NULL,NULL},
  26.                             {&object[2],BB_Slider,1,100,100,NULL,NULL},
  27.                             {&object[3],BB_Check,0,0,0,NULL,NULL},
  28.                             {&object[4],BB_Slider,0,100,70,NULL,NULL},
  29.                             {&object[5],BB_Slider,0,20,1,NULL,NULL},
  30.                             {NULL,BB_VGroup_End,0,0,0,NULL,NULL} };
  31.  
  32. struct BB_Message message;
  33. struct BB_Screeninfo *screeninfo;
  34.  
  35. int a,*top,*bot;
  36. struct RastPort *rp;
  37.  
  38.  
  39. void setup (void)
  40. {
  41.   int i;
  42.   a=0;
  43.   SetAPen (rp,0);
  44.   Move (rp,0,screeninfo->height-1);
  45.   Draw (rp,screeninfo->width-1,screeninfo->height-1);
  46.   Move (rp,0,screeninfo->height-2);
  47.   Draw (rp,screeninfo->width-1,screeninfo->height-2);
  48.   for (i=0;i<screeninfo->width;i++)
  49.   {
  50.     top[i]=screeninfo->height-2;
  51.     bot[i]=screeninfo->height;
  52.   }
  53. }
  54.  
  55.  
  56. void blank (void)
  57. {
  58.   int i,x,c,b=0;
  59.  
  60.   rp=&screeninfo->bbscreen->RastPort;
  61.  
  62.   top=calloc (screeninfo->width,sizeof (int));
  63.   bot=calloc (screeninfo->width,sizeof (int));
  64.  
  65.   if (top==NULL || bot==NULL)
  66.     return;
  67.  
  68.   if (object[2].set)
  69.     b=BBL_GetDarkestPen (screeninfo->bbscreen);
  70.  
  71.   ScreenToFront (screeninfo->bbscreen);
  72.  
  73.   if (!CheckSignal (SIGBREAKF_CTRL_C))
  74.   {
  75.     BBL_ModuleRunning ();
  76.     if (BBL_FadeDown (screeninfo->bbscreen,object[3].set,object[4].set))
  77.     {
  78.       setup ();
  79.       do
  80.       {
  81.         WaitTOF ();
  82.         for (i=1;i<=object[1].set;i++)
  83.         {
  84.           x=drand48 ()*screeninfo->width;
  85.           if (top[x]>=0)
  86.           {
  87.             do
  88.             {
  89.               c=ReadPixel (rp,x,top[x]);
  90.               top[x]--;
  91.             } while (c==b && top[x]!=-1);
  92.             if (top[x]==-1 && c==b)
  93.               a++;
  94.             else
  95.               top[x]++;
  96.             if (c!=b)
  97.             {
  98.               SetAPen (rp,b);
  99.               WritePixel (rp,x,top[x]);
  100.               if (drand48 ()*3<1)
  101.               {
  102.                 bot[x]--;
  103.                 SetAPen (rp,c);
  104.                 WritePixel (rp,x,bot[x]);
  105.               }
  106.             }
  107.             else
  108.               if (a==screeninfo->width)
  109.               {
  110.                 BBL_CopyOriginalScreen (screeninfo->bbscreen);
  111.                 setup ();
  112.               }
  113.           }
  114.         }
  115.       } while (!CheckSignal (SIGBREAKF_CTRL_C));
  116.     }
  117.   }
  118.   return;
  119. }
  120.  
  121.  
  122. void main(int argc,char **argv)
  123. {
  124.   int i;
  125.  
  126.   if (!(BlitzBlankBase=OpenLibrary ("blitzblank.library",BLITZBLANKLIB_VER)))
  127.     exit (0);
  128.  
  129.   message.flags=BBF_CloneScreen;
  130.   message.first=&object[0];
  131.  
  132.   if (strcmp (argv[1],"BLANK")==0)
  133.   {
  134.     StrToLong (argv[3],(long *) &screeninfo);
  135.     BBL_SendMessage (&message,argv[2]);
  136.     if (screeninfo->bbscreen)
  137.       blank ();
  138.     BBL_BlankDone ();
  139.   }
  140.   else
  141.   {
  142.     message.infotext=BBL_GetString (230,text[0]);
  143.     for (i=1;i<=4;i++)
  144.       object[i].label=BBL_GetString (230+i,text[i]);
  145.     if (strcmp (argv[1],"CONFIG")==0)
  146.     {
  147.       BBL_SendMessage (&message,argv[2]);
  148.     }
  149.     else
  150.     {
  151.       message.first=NULL;
  152.       BBL_SendMessage (&message,argv[2]);
  153.     }
  154.   }
  155.   CloseLibrary (BlitzBlankBase);
  156.   exit (0);
  157. }
  158.  
  159.